package com.brokendust.client.config.module.pullpanel;

import com.brokendust.client.api.util.image.ImageControl;
import com.brokendust.client.config.module.ComponentJson;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.HashMap;
import java.util.Map;

public class PullPanelJson implements ComponentJson {
    public String type;
    private String objectID;
    private String image;
    private int width;
    private int height;
    private int displayWidth;
    private int displayHeight;
    private int startX;
    private int startY;
    private int position;
    private int x;
    private int y;
    private Map<String, String> objectList;

    public PullPanelJson() {
        this.type = "PullPanel";
        this.objectList = new HashMap<String, String>();
    }

    public static PullPanelJson readJSON(String string) {
        GsonBuilder builder = new GsonBuilder();
        Gson gson = builder.create();
        return gson.fromJson(string, PullPanelJson.class);
    }

    public void refreshSize() {
        if (this.width == 0) {
            this.width = ImageControl.getWidth(this.image);
        }
        if (this.height == 0) {
            this.height = ImageControl.getHeight(this.image);
        }
    }

    public String getType() {
        return this.type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getObjectID() {
        return this.objectID;
    }

    public void setObjectID(String objectID) {
        this.objectID = objectID;
    }

    public String getImage() {
        return this.image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public int getWidth() {
        return this.width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return this.height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getDisplayWidth() {
        return this.displayWidth;
    }

    public void setDisplayWidth(int displayWidth) {
        this.displayWidth = displayWidth;
    }

    public int getDisplayHeight() {
        return this.displayHeight;
    }

    public void setDisplayHeight(int displayHeight) {
        this.displayHeight = displayHeight;
    }

    public int getStartX() {
        return this.startX;
    }

    public void setStartX(int startX) {
        this.startX = startX;
    }

    public int getStartY() {
        return this.startY;
    }

    public void setStartY(int startY) {
        this.startY = startY;
    }

    public int getPosition() {
        return this.position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    public int getX() {
        return this.x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return this.y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Map<String, String> getObjectList() {
        return this.objectList;
    }

    public void setObjectList(Map<String, String> objectList) {
        this.objectList = objectList;
    }
}
